<?php
class user {

    private $_params;

    public function __construct($params) {
        $this->_params = $params;
    }

    public function sessionAction() {

        if (isset($_SESSION["user_id"])) {
            return $_SESSION["user_id"];
        }
        return null;
    }

    public function loginAction() {

        $user = ENV::$db->query("
            SELECT user_id
            FROM user_user
            WHERE 1
                AND user_loginname = \"" . $this->_params["user_loginname"] . "\"
                AND user_password =\"" . $this->_params["user_password"] . "\"
        ");

        $user = $user->fetch();
        $_SESSION["user_id"] = $user["user_id"];

        return $user["user_id"];
    }
}